package untiring.services;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import untiring.helper.ServletImageUtil;
import untiring.interfaces.ProductDAO;
import untiring.interfaces.ProductService;
import untiring.models.ProductVO;

@Service
public class ProductServiceImpl implements ProductService{

	
	@Autowired
	private ProductDAO productDAO;
	@Autowired
	private ServletImageUtil imageUtil;
	
	@Override
	public String newProduct(ProductVO p) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ProductVO> readProduct() {
		return productDAO.selectProduct();
	}

	@Override
	public ProductVO readOneProduct(String pno) {
		
		return productDAO.selectOneProduct(pno);
	}

	@Override
	public String modifyProduct(ProductVO p) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String removeProduct(String pno) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public byte[] viewImage(ProductVO p, HttpServletResponse res) throws Exception {
		 ProductVO i = productDAO.selectImage(p);
	      String fname = i.getUuid() + i.getIno();
	      return imageUtil.processImage(fname, res);
	}

}
